import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PriceVO, PriceForm, PriceQuery } from '@/api/wuliu/price/types';

/**
 * 查询价格计算方案列表
 * @param query
 * @returns {*}
 */

export const listPrice = (query?: PriceQuery): AxiosPromise<PriceVO[]> => {
  return request({
    url: '/wuliu/price/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询价格计算方案详细
 * @param id
 */
export const getPrice = (id: string | number): AxiosPromise<PriceVO> => {
  return request({
    url: '/wuliu/price/' + id,
    method: 'get'
  });
};

/**
 * 新增价格计算方案
 * @param data
 */
export const addPrice = (data: PriceForm) => {
  return request({
    url: '/wuliu/price',
    method: 'post',
    data: data
  });
};

/**
 * 修改价格计算方案
 * @param data
 */
export const updatePrice = (data: PriceForm) => {
  return request({
    url: '/wuliu/price',
    method: 'put',
    data: data
  });
};

/**
 * 删除价格计算方案
 * @param id
 */
export const delPrice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/wuliu/price/' + id,
    method: 'delete'
  });
};
